/**
 * @Author YuanYuan
 * @Date 2022/9/14
 * @Time 11:44
 */
class Counter {
    public int count = 0;
    private static Object locker = new Object();
    public void increase1 () {
        synchronized (locker) {
            count++;
        }
    }
    public void increase () {
        synchronized (Counter.class) {
            count++;
        }
    }
}

public class TestDemo3 {

    public static void main(String[] args) {
        Counter counter = new Counter();
        Counter counter1 = new Counter();

        Thread thread = new Thread(()-> {
            for (int i = 0; i < 10_0000; i++) {
                counter.count++;
            }
        });

        Thread thread1 = new Thread(()-> {
            for (int i = 0; i < 10_0000; i++) {
                counter1.count++;
            }
        });

        thread.start();
    }
}
